layui.use(['jquery', 'form', 'layer'], function (data) {
    var $ = layui.jquery,
        form = layui.form,
        layer = layui.layer;


    form.on('submit(addPickMaterial)', function (data) {
        var index = top.layer.msg("数据提交中，请稍后", {
            icon: 16, // 图标
            time: true,  // 不关闭
            shade: 0.8 // 设置遮罩透明度
        });
        var formData = data.field;
        var url = ctx + "/production/addPickMaterial";

        $.ajax({
            type: "post",
            data: formData,
            url: url,
            success: function (data) {
                if (data.code == 200) {
                    layer.close(index);
                    layer.msg(data.msg);
                    var pageIndex = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(pageIndex);


                } else {
                    layer.closeAll("iframe");

                    layer.msg(data.msg);
                    layer.close(index);
                }
            }, error: function (data) {
                layer.closeAll("iframe");
                layer.msg(data.msg);
                layer.close(index);
            }
        })

        return false;

    })


})